package com.yf.test;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONArray;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

//@RunWith(SpringJUnit4ClassRunner.class)
//@SpringBootTest
public class HelloWored {


    @Test
    public void test01() {
//        System.out.println(":xxx");
//
////        String areamm="100*200";
//        String areamm="100*200";
////        int length = areamm.split("[^0-9]").length;
////        String[] xes = areamm.split("[^0-9]");
//        String[] xes = areamm.split("[^0-9]");
//
//        Long res= Long.valueOf(Long.parseLong(xes[0]) > Long.parseLong(xes[1]) ? xes[0] : xes[1]);
//
//        System.out.println(res);

        //
//        Long arem = 290L;
//        if (arem >= 300L) {
//            System.out.println("111");
//        } else if (2 > 1) {
//            System.out.println(arem);
//        }

//
//        Double jul = 9.0d;
//        Double jul1 = 11.0d;
//        Double jul2 = 11.3d;
//        Double jul3 = 11.01d;
//
//        DecimalFormat df = new DecimalFormat("#.##");
//        String format1 = df.format(jul);
//        String format2 = df.format(jul1);
//        String format3 = df.format(jul2);
//        String format4= df.format(jul3);
//        System.out.println(format1);
//        System.out.println(format2);
//        System.out.println(format3);
//        System.out.println(format4);

//        System.out.println(new BigDecimal(jul).stripTrailingZeros().toPlainString() + "");
//        System.out.println(new BigDecimal(jul1).stripTrailingZeros().toPlainString() + "");
//        System.out.println(new BigDecimal(jul2).stripTrailingZeros().toPlainString() + "");


        DecimalFormat df = new DecimalFormat("##%"); //百分比，不保留小数
        DecimalFormat df2 = new DecimalFormat("#.#%"); //百分比，并取1位小数

        //以百分比方式计数，并取1位小数
//        System.out.println(new DecimalFormat("#.#%").format(pi));//314.1%


//        String format = decimalFormat.format(5d / 10d);
        long ri1Count = 56L;
        int pipeCount = 101;
        String replace = df2.format(ri1Count / (double) pipeCount).replace("%", "");
        System.out.println(replace);

    }

    @Test
    public void test2() {

        List<String> list = new ArrayList<>();
        list.add("YYLY114");
        list.add("ysl14");
        list.add("ysl24");
        list.add("YYLY15");
        list.add("YYLY150");
        list.add("YYLY47");
        list.add("YYLY91");
        list.add("YYLY94");
        list.add("YYLW13");

        list.sort(new CustomComparator());
        for (String str : list) {
            System.out.println(str);
        }

    }


    //String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);


    @Test
    public void test3() {

//        String url="cangzhou/check/20240109/1704790351494_image.png";
//
//        String suffix = url.substring(url.lastIndexOf(".") + 1);
//        System.out.println(suffix);


//4601 460102
//        String proCode="461";
//        String roadCode="460102";
//
//        if(roadCode.startsWith(proCode)){
//            System.out.println("xxx");
//        }
        String str1 = "昆山普乐赛思金属制品有限公司主支管";
        String pipeType = str1.substring(str1.length() - 2);
        System.out.println(pipeType);

    }


    @Test
    public void test4() {
//       String str="LINESTRING ( 120.88757506 31.45039545, 120.88765396 31.45039558)";
//        String coordinate2000 = str.replace("LINESTRING ( ", "[").replace(")", "]")
//                .trim().replace(" ", ",").replace(",,", ",");
//
//        System.out.println(coordinate2000);
//
//        JSONArray objects = new JSONArray(coordinate2000);
//        System.out.println(objects);

        String str = "顺流(SL)";
        String ss2 = str.replaceAll("\\(.*?\\)", "");
        System.out.println(ss2);

    }


    public static class CustomComparator implements Comparator<String> {
        @Override
        public int compare(String s1, String s2) {
            // 提取两个字符串的数字部分并转换为int型
            int num1 = Integer.parseInt(s1.replaceAll("\\D+", ""));
            int num2 = Integer.parseInt(s2.replaceAll("\\D+", ""));
            return num1 - num2;
        }
    }


}
